import { reqBannerList, reqCategoryList, reqFloorList } from '@/api'
const state = {
  categoryList: [],
  bannerList: [],
  floorList:[]
}
const mutations = {
  //获取三级分类数据
  CATEGORYLIST(state, categoryList) {
    state.categoryList = categoryList
  },
  //获取首页轮播图和其右侧模块数据
  GETBANNERLIST(state, bannerList) {
    state.bannerList = bannerList
  },
  //获取floor组件数据
  GETFLOORLIST(state,floorList){
    state.floorList=floorList
  }
}
const actions = {
  //获取三级分类数据
  async categoryList({ commit }) {
    let result = await reqCategoryList()
    if (result.code == 200) {
      commit('CATEGORYLIST', result.data)
    }
  },
  //获取首页轮播图和其右侧模块数据
  async getBannerList({ commit }) {
    let result = await reqBannerList()
    if (result.code == 200) {
      commit('GETBANNERLIST', result.data)
    }
  },
  //获取floor组件数据
  async getFloorList({commit}){
    let result =await reqFloorList()
    if(result.code==200){
      commit('GETFLOORLIST',result.data)
    }
  }
}
const getters = {}
export default {
  state,
  mutations,
  actions,
  getters
}
